/*    */ package com.alipaydb.util;
/*    */ 
/*    */ import com.alipaydb.config.AlipayConfig;
/*    */ import java.io.FileWriter;
/*    */ import java.io.IOException;
/*    */ import java.util.ArrayList;
/*    */ import java.util.Collections;
/*    */ import java.util.Hashtable;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ 
/*    */ public class AlipayCore
/*    */ {
/*    */   public static String buildMysign(Map<String, String> sArray)
/*    */   {
/* 32 */     String prestr = createLinkString(sArray);
/* 33 */     prestr = prestr + AlipayConfig.key;
/* 34 */     String mysign = AlipayMd5Encrypt.md5(prestr);
/* 35 */     return mysign;
/*    */   }
/*    */ 
/*    */   public static Map<String, String> paraFilter(Map<String, String> sArray)
/*    */   {
/* 45 */     Map result = new Hashtable();
/*    */ 
/* 47 */     if ((sArray == null) || (sArray.size() <= 0)) {
/* 48 */       return result;
/*    */     }
/*    */ 
/* 51 */     for (String key : sArray.keySet()) {
/* 52 */       String value = (String)sArray.get(key);
/* 53 */       if ((value == null) || (value.equals("")) || (key.equalsIgnoreCase("sign")) || (key.equalsIgnoreCase("sign_type")))
/*    */       {
/*    */         continue;
/*    */       }
/* 57 */       result.put(key, value);
/*    */     }
/*    */ 
/* 60 */     return result;
/*    */   }
/*    */ 
/*    */   public static String createLinkString(Map<String, String> params)
/*    */   {
/* 70 */     List keys = new ArrayList(params.keySet());
/* 71 */     Collections.sort(keys);
/*    */ 
/* 73 */     String prestr = "";
/*    */ 
/* 75 */     for (int i = 0; i < keys.size(); i++) {
/* 76 */       String key = (String)keys.get(i);
/* 77 */       String value = (String)params.get(key);
/*    */ 
/* 79 */       if (i == keys.size() - 1)
/* 80 */         prestr = prestr + key + "=" + value;
/*    */       else {
/* 82 */         prestr = prestr + key + "=" + value + "&";
/*    */       }
/*    */     }
/*    */ 
/* 86 */     return prestr;
/*    */   }
/*    */ 
/*    */   public static void logResult(String sWord)
/*    */   {
/* 94 */     FileWriter writer = null;
/*    */     try {
/* 96 */       writer = new FileWriter(AlipayConfig.log_path);
/* 97 */       writer.write(sWord);
/*    */     } catch (Exception e) {
/* 99 */       e.printStackTrace();
/*    */     } finally {
/* 101 */       if (writer != null)
/*    */         try {
/* 103 */           writer.close();
/*    */         } catch (IOException e) {
/* 105 */           e.printStackTrace();
/*    */         }
/*    */     }
/*    */   }
/*    */ }

/* Location:           F:\电商\commons-utils.jar
 * Qualified Name:     com.alipaydb.util.AlipayCore
 * JD-Core Version:    0.6.0
 */